<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <script src="https://unpkg.com/vue/dist/vue.js"></script>
    <script src="https://unpkg.com/element-ui/lib/index.js"></script>
    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css"></link>
</head>

<body>
    <div id="app">
        <el-col span="4">
            <el-menu background-color="#545c64" text-color="#fff" active-text-color="#ffd04b" id="menu">
                <child v-for="item in itemlist" :item-data="item"></child>
            </el-menu>

        </el-col>

    </div>
</body>
<script type="text/x-template" id="main-template">
    <div>
        <el-menu-item v-if="itemData.nodes==null" :index="itemData.index">
            <span>{{itemData.text}}</span>
        </el-menu-item>

        <el-submenu v-if="itemData.nodes!=null" :index="itemData.index">
            <template slot="title">
                <span>{{itemData.text}}</span>
            </template>
            <!--调用组件自身，循环item的nodes，实现递归 -->
            <child v-for="item in itemData.nodes" :item-data="item"></child>
        </el-submenu>
    </div>

</script>
<script>
    // 注册
    Vue.component('child', {
        props: ['itemData'],
        // 同样也可以在 vm 实例中像 “this.message” 这样使用
        template: '#main-template'
    })
    // 创建根实例
    new Vue({
        el: '#app',
        data: {
            itemlist: [{
                "mouduleurl": "",
                "text": "后台管理",
                "value": "0001",
                "index": "1",
                "nodes": [{
                    "mouduleurl": "pages/config/config_list.html",
                    "text": "系统参数",
                    "value": "00010001",
                    "index": "1-1",
                }, {
                    "mouduleurl": "pages/dmp/table_list.html",
                    "text": "数据表结构",
                    "value": "00010002",
                    "index": "1-2",
                    "nodes": [{
                        "mouduleurl": "pages/config/config_list.html",
                        "text": "数据表关联管理",
                        "value": "00010002001",
                        "index": "1-2-1",
                    }]
                }, {
                    "mouduleurl": "pages/module/module_settinglist.html",
                    "text": "模块地址",
                    "value": "00010003",
                    "index": "1-3",
                }],

            }, {
                "mouduleurl": "",
                "text": "文章管理",
                "value": "0002",
                "index": "2",
                "nodes": [{
                    "mouduleurl": "pages/article/article_list.html",
                    "text": "文章列表",
                    "value": "00020001",
                    "index": "2-1",
                }],

            }, {
                "mouduleurl": "",
                "text": "爬虫专题",
                "value": "0003",
                "index": "3",
                "nodes": [{
                    "mouduleurl": "pages/spider/music/music_search.html",
                    "text": "网易云音乐",
                    "value": "00030001",
                    "index": "3-1",
                }],

            }, {
                "mouduleurl": "",
                "text": "测试4",
                "value": "0004",
                "index": "4",


            }]
        }
    })
</script>

</html>